﻿using System;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Caching;
using Volo.Abp.Domain;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.Localization;
using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Modularity;
using Volo.Abp.ObjectExtending.Modularity;
using Volo.Abp.Threading;
using YunxSoft.Abp.LanguageManagement.Localization;

namespace YunxSoft.Abp.LanguageManagement;

[DependsOn(
    typeof(LanguageManagementDomainSharedModule),
    typeof(AbpDddDomainModule),
    typeof(AbpCachingModule),
    typeof(AbpAutoMapperModule)
)]
public class LanguageManagementDomainModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        // Configure<AbpLocalizationOptions>(options => options.GlobalContributors.Add<DynamicLocalizationResourceContributor>());
        Configure<AbpExceptionLocalizationOptions>(options => options.MapCodeNamespace("LanguageManagement", typeof(LanguageManagementResource)));
        context.Services.AddAutoMapperObjectMapper<LanguageManagementDomainModule>();
        Configure<AbpAutoMapperOptions>(options => options.AddProfile<LanguageManagementDomainAutoMapperProfile>(true));
        Configure<AbpDistributedEntityEventOptions>(options =>
        {
            options.EtoMappings.Add<Language, LanguageEto>(typeof(LanguageManagementDomainModule));
            options.EtoMappings.Add<LanguageText, LanguageTextEto>(typeof(LanguageManagementDomainModule));
        });
    }
}